package com.api.shopapi.service.impl;


import com.api.shopapi.entity.Complaint;
import com.api.shopapi.entity.dto.ComplaintDTO;
import com.api.shopapi.mapper.ComplaintMapper;
import com.api.shopapi.service.ComplaintService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @author maochuan
 */
@Service("ComplaintServiceImplOne")
public class ComplaintServiceImpl implements ComplaintService {
    @Autowired
    private ComplaintMapper complaintMapper;


    @Override
    public int insert(Complaint complaint) {
        return complaintMapper.insert(complaint);
    }

    @Override
    public int update(Complaint complaint) {
        return complaintMapper.update(complaint);
    }

    @Override
    public PageInfo<ComplaintDTO> getPageList(int pageIndex, int pageSize,  String governmentCode, int status, int type, Date startTime, Date endTime) {
        PageHelper.startPage(pageIndex,pageSize);
        List<ComplaintDTO> complaintList =complaintMapper.getPageList(governmentCode,status,type,startTime,endTime);
        return new PageInfo<>(complaintList);
    }

    @Override
    public ComplaintDTO getByComplaintCode(String complaintCode) {
        return complaintMapper.getByComplaintCode(complaintCode);
    }
}
